package com.maxjay.system.menu.model;

import java.util.ArrayList;
import java.util.List;

public class MenuTreeNode {

	private String id;
	private String text;
	private String url;
	private String type;
	private String parentId;
	private MenuTreeNode parent;
	private boolean isLeaf = false;
	private List<MenuTreeNode> children = new ArrayList<MenuTreeNode>(0);
	
	public MenuTreeNode() {}

	public MenuTreeNode(String id, String text) {
		this.id = id;
		this.text = text;
	}
	
	public MenuTreeNode(String id, String text, String url) {
		this.id = id;
		this.text = text;
		this.url = url;
	}
	
	public MenuTreeNode(String id, String text, String url, String parentId) {
		this.id = id;
		this.text = text;
		this.url = url;
		this.parentId = parentId;
	}
	
	public void addChild(MenuTreeNode childNode) {
		this.children.add(childNode);
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public MenuTreeNode getParent() {
		return parent;
	}

	public void setParent(MenuTreeNode parent) {
		this.parent = parent;
		parent.addChild(this);
	}

	public List<MenuTreeNode> getChildren() {
		return children;
	}

	public void setChildren(List<MenuTreeNode> children) {
		this.children = children;
	}

	public boolean isLeaf() {
		return isLeaf;
	}

	public void setIsLeaf(boolean isLeaf) {
		this.isLeaf = isLeaf;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("菜单ID：").append(id).append("，菜单名：").append(text).append("，父菜单ID：").append(parentId);
		return sb.toString();
	}

}
